package Task15;

public class Main2 {
    public int findMinimum(int n, int[] left, int[] right) {
        //左边手套总数
        int leftsum = 0;
        //右边手套总数
        int rightsum = 0;
        //左边手套颜色最小数量
        int leftmin = 14;
        //右边手套颜色最小数量
        int rightmin = 14;
        int sum = 0;
        for(int i = 0;i < n;i++){
            if(left[i]*right[i] == 0){
                sum += left[i] + right[i];
            }else{
                leftsum += left[i];
                rightsum += right[i];
                if(leftmin > left[i]){
                    leftmin = left[i];
                }
                if(rightmin > right[i]){
                    rightmin = right[i];
                }
            }
        }
        return Math.min(leftsum - leftmin + 1,rightsum - rightmin + 1) + 1 + sum;
    }
}
